<template>
    <Modal title="设置负责人" @on-visible-change="showModal" :closable="false" v-model="show" :mask-closable="false">
        <el-form ref="back" label-position="right" label-width="80px">
            <el-form-item label="分配员工" prop="subUserId">
                <el-select size="small" filterable v-model="subUserId" placeholder="分配员工" style="width: 240px">
                    <el-option v-for="(mer,ind) in subMerchants" :value="mer.id" :label="mer.merName" :key="ind"></el-option>
                </el-select>
            </el-form-item>
        </el-form>
        <div slot="footer">
            <el-button @click="cancel">取消</el-button>
            <el-button @click="ok" type="success" :loading="loading">修改</el-button>
        </div>
    </Modal>
</template>
<script>
export default {
    name: "CXiapiCost",
    data() {
        return {
            loading: false,
            show: false,
            ids:null,
            subUserId:null,
            subMerchants: [],
        }
    },
    props: [
        
    ],
    methods: {
        showModal: function(val) {
            if (val) {
                
                this.getSubMerchant();
            } else {
                this.ids = null;
            }
        },
        getList: function() {
            var me = this;
            me.loading = true;
            me.$http.post("/storageproduct/doSubuser.do", { ids: me.ids, subUserId: me.subUserId }).then(response => {
                me.loading = false;

                var body = response;
                if (body.status == 0) {

                    me.$emit('ok');
                    me.successMessage("设置成功");
                    me.show=false;
                }
                else{
                    me.errorMessage(body.info);
                }

            }, response => {
                me.loading = false;
            });
        },
        ok: function() {
            this.getList();
        },
        getSubMerchant: function() {
            var me = this;
            var params = {
                current: 1,
                pageSize: 1000
            };
            me.getLoading = true;
            me.$http.post("/submerchant/getList.do", params).then(response => {
                var body = response;
                if (body.status == 0) {

                    me.subMerchants = body.obj.list;

                }
                me.getLoading = false;
            }, response => {
                me.getLoading = false;
            });
        },
        cancel: function() {
            this.show = false;
            this.$emit('cancel')
        },
        showDialog: function(ids) {
            this.ids=ids;
            this.show = true;
        }

    }
}
</script>
<style scoped>
.ivu-alert-with-desc {
    padding: 0px 16px;
}

.time {
    font-size: 14px;
    font-weight: bold;
}

.content {
    padding-left: 5px;
    word-wrap: break-word;
}
</style>